// pages/member/generalize.js

Page({

  /**
   * 页面的初始数据
   */
  data: {
    userInfoAvatar: '',
    nickName: '',
    imgwidth: 0,
    imgheight: 0,
    imgwidth2:0,
    imgheight2:0,
    carts: [
    ],
  },
  imageLoad: function (e) {
    var _this = this;
    var $width = e.detail.width,    //获取图片真实宽度  
      $height = e.detail.height,
      ratio = 1;   //图片的真实宽高比例  
    var viewHeight = 108,           //设置图片显示宽度，  
      viewWidth = 108 / ratio;    //计算的高度值     
    this.setData({
      imgwidth: viewWidth,
      imgheight: viewHeight
    })
  },
  Loadtwo: function (e) {
    var _this = this;
    var $width = e.detail.width,    //获取图片真实宽度  
      $height = e.detail.height,
      ratio = 1;   //图片的真实宽高比例  
    var viewHeight2 = 50,           //设置图片显示宽度，  
      viewWidth2 = 50 / ratio;    //计算的高度值     
    this.setData({
      imgwidth2: viewWidth2,
      imgheight2: viewHeight2
    })
  },
  onLoad: function () {
    var that = this;
    wx.getUserInfo({
      success: function (res) {
        // success  
        that.setData({
          nickName: res.userInfo.nickName,
          userInfoAvatar: res.userInfo.avatarUrl,
          carts: [
            { photo: res.userInfo.avatarUrl, name: res.userInfo.nickName, icon:'/images/icon/diamond@3x.png' ,grade:'钻石会员' ,date:'2018-06-10'        },
            { photo: res.userInfo.avatarUrl, name: res.userInfo.nickName, icon: '/images/icon/diamond@3x.png', grade: '钻石会员', date: '2018-06-10' },
            { photo: res.userInfo.avatarUrl, name: res.userInfo.nickName, icon: '/images/icon/diamond@3x.png', grade: '钻石会员', date: '2018-06-10' },
            { photo: res.userInfo.avatarUrl, name: res.userInfo.nickName, icon: '/images/icon/diamond@3x.png', grade: '钻石会员', date: '2018-06-10' },
            { photo: res.userInfo.avatarUrl, name: res.userInfo.nickName, icon: '/images/icon/diamond@3x.png', grade: '钻石会员', date: '2018-06-10' },
            { photo: res.userInfo.avatarUrl, name: res.userInfo.nickName, icon: '/images/icon/diamond@3x.png', grade: '钻石会员', date: '2018-06-10' },
          ],
        })
      },
      fail: function () {
        // fail  
        console.log("获取失败！")
      },
      complete: function () {
        // complete  
        console.log("获取用户信息完成！")
      }
    })
  }
  
})